export function GetData(data, course_chapter_id) {
    var full_score = 0;
    var my_score = 0;
    var chapter_data = {lessons: []};
    var Column = {
        'categories': [],
        'series': [{
            'name': '总分',
            'data': [],
            'color': '#2fc25b'
        }, {
            'name': '得分',
            'data': [],
            'color': '#1890ff'
        }]
    };
    var Line = {
        'categories': [],
        'series': [{
            'name': '章节得分',
            'data': [],
            'color': '#FF7F00',
        }]
    };
    for(var i = 0;i < data.data.chapters.length;i++) {
        full_score = 0;
        my_score = 0;
        for(var j = 0;j < data.data.chapters[i].lessons.length;j++) {
            full_score += data.data.chapters[i].lessons[j].score;
            my_score += data.data.chapters[i].lessons[j].user_score;
        }
        if(full_score != 0) {
            Line.series[0].data.push(my_score);
            Line.categories.push({'title': 'ch' + i,
                'chapter_title': data.data.chapters[i].title,
                'full_score': full_score,
                'my_score': my_score,
                'rate': parseInt(my_score * 100 / full_score).toString() + '%'});
        }
        if(i > 0 && data.data.chapters[i - 1].id == course_chapter_id) {
            chapter_data = data.data.chapters[i - 1];
            break;
        }
    }
    for(i = 0;i < chapter_data.lessons.length;i++) {
        Column.categories.push(i + ':' + chapter_data.lessons[i].title);
        Column.series[0].data.push(chapter_data.lessons[i].score);
        Column.series[1].data.push(chapter_data.lessons[i].user_score);
    }
    return {'Column': Column,
        'Line': Line,
        'chapter_data': chapter_data};
}
